import * as echarts from "echarts";
import { EChartsOption } from "echarts";
export default function (ele: HTMLElement) {
  const echartInstance = echarts.init(ele);
  const echartSetOption = (options: EChartsOption) => {
    echartInstance.setOption(options);
  };
  const echartResize = () => {
    echartInstance.resize();
  };
  window.addEventListener("resize", () => {
    echartInstance.resize();
  });
  return { echartInstance, echartSetOption, echartResize };
}
